<div class="doc-item" id="doc-844"><h2 class="doc-item-name">expression-info<span class="namespace">(clojure.contrib.repl-utils)</span></h2><ul class="var-arglists"><li>(<span class="var-name">expression-info</span>  expr)</li></ul><div class="var-docstring"><p>Uses the Clojure compiler to analyze the given s-expr.  Returns
  a map with keys :class and :primitive? indicating what the compiler
  concluded about the return value of the expression.  Returns nil if
  not type info can be determined at compile-time.
  
  Example: (expression-info '(+ (int 5) (float 10)))
  Returns: {:class float, :primitive? true}</p></div><div class="var-source"><pre>; clojure/contrib/repl_utils.clj:162
(defn expression-info
  [expr]
  (let [fn-ast (Compiler/analyze Compiler$C/EXPRESSION `(fn [] ~expr))
        expr-ast (.body (first (.methods fn-ast)))]
    (when (.hasJavaClass expr-ast)
      {:class (.getJavaClass expr-ast)
       :primitive? (.isPrimitive (.getJavaClass expr-ast))})))</pre></div><div class="license"><p>Copyright (c) Rich Hickey. All rights reserved.</p><p>The use and distribution terms for this software are covered by the <a href="http://opensource.org/licenses/eclipse-1.0.php">Eclipse Public License 1.0</a>, which can be found in the file
          epl-v10.html at the root of this distribution. By using this software
          in any fashion, you are agreeing to be bound by the terms of this
          license. You must not remove this notice, or any other, from this
          software.</p></div></div>